Productive R Workflow Module 3
1 Lesson 1
1.1 Clean tables
Author discusses two preferred methods for incorporating tables in Quarto documents. Different approaches are discussed in this link.
1.2 Interactive tables with DT
Here is one of my go-to techniques when showcasing Quarto 😍.
With just two extra lines of code, you can unveil an interactive table that allows:
sorting
filtering
searching
pagination
It offers readers the convenience of accessing the data directly within your report. The magic of this functionality rests in the DT library. DT stands for DataTables: the JavaScript library supports it.
1.3 Static tables with kable() from the package knitr
Code
| species | average_bill_length |
|---|---|
| Adelie | 38.79139 |
| Chinstrap | 48.83382 |
| Gentoo | 47.50488 |
2 Lesson 2
Interactive tables
An interactive chart allows the user to perform actions: zooming, hovering a marker to get a tooltip, choosing a variable to display and more.
R offers a set of packages called the html widgets.
They allow to build interactive charts directly from R. 🔥
This course is not about data visualization and I already curated the best packages for interactive dataviz in the R graph gallery.
2.1 Plotly and ggplotly()
Code
ggplotly provides information for each point displayed in the graph. On the following chart you can zoom, hover, pan, export to png and more!
I find plotly so convenient: it’s an instant win without the need to learn anything new!
However, it’s not always the ideal choice. For instance Leaflet is better suited for mapping, and Dygraph excels in handling time series data. I’ve detailed these alternatives in the R Graph Gallery if you’re interested!
Also, remember that not all graphs require interactivity. For example, a basic bar chart remains just as effective in its static form, containing all the necessary information.
3 Lesson 3
Report header
In Quarto, you have the flexibility to include extensive information in the document header.
While the official documentation offers a comprehensive list of options, it’s important to strike a balance to prevent overwhelming readers.
Here’s an example of a Quarto header that effectively incorporates these elements in the YAML section of the Quarto document :
title: "Exploring the Simpson's Paradox..."
subtitle: "And simultaneously demonstrating ..."
description: "This document is..."
author:
name: "Yan Holtz"
affiliation: "Independant 😀"
email: yan.holtz.data@gmail.com
keywords: "Quarto, Paradox, Data Analysis"
date: today
3.0.1 Header appearance
With our informative header in place, let’s enhance its visual appeal.
One effective method is to utilize the title-block-banner option to introduce a background color, adding depth to the header. It subtly elevates its presence.
Quarto opens up endless possibilities for customization.
→ The Front Matter and Title blocks sections provide a comprehensive list of out-of-the-box options, covering licenses, copyrights, citations, multiple authors, metadata labels, and more.
→ Later in the course, we’ll explore CSS techniques to customize any element within the report.
→ For advanced users, template partials offer the ability to build the header structure from scratch, although this is a more advanced feature.
4 Lesson 4
Apply your style with CSS
his course teaches you how to transform your R code into a visually appealing report in HTML format.
Essentially, we’re creating a miniature website 🔥!
It is time to understand what HTML is, and explore how to personalize it using CSS, a stylesheet language.
Hello World!
I am a tiny website
When encountering a tag like h1, it recognizes it as a level 1 title and know how to format it accordingly. Same with the p tag that stands for paragraph, and all other tag types.
4.1 Style it with CSS
CSS is the language we use to style an HTML document.
Basically, we could create a file called style.css and add the following content in it:
h1 {
color: red;
}
Quarto, HTML and CSS